<!DOCTYPE html>
<!--[if lt IE 7]>      <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html lang="en" ng-app="myApp" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" ng-app="myApp" class="no-js"> <!--<![endif]-->
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>中华爱情网</title>
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
  <link rel="shortcut icon" href="favicon.ico" />

  <link rel="stylesheet" href="/bower_components/lumx/dist/lumx.css">
  <link rel="stylesheet" href="/bower_components/loading-bar.min.css">
  <link rel="stylesheet" href="/css/app.css">

</head>
<body >


<div ng-controller="appCtrl" flex-container="row" style="position:relative;">
    <div flex-item="12" class="tc-white-2  bgc-grey-300" >

      <div ng-view="true" ></div>
    </div>

    <!-- <img type="button" style="position:fixed;right:0px;bottom:10px;z-index:9999;-webkit-tap-highlight-color:rgba(255,255,255,0);" class="right" ng-click="go_top()"src="/css/go_top.png"> -->
</div>

<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<script src="/bower_components/jquery/jquery.qrcode.js"></script>
<script src="/bower_components/jquery/qrcode.js"></script>
<script src="/bower_components/velocity/velocity.min.js"></script>
<script src="/bower_components/moment/min/moment-with-locales.min.js"></script>
<script src="/bower_components/angular/angular.min.js"></script>
<script src="/bower_components/angular-route/angular-route.js"></script>
<script src="/bower_components/ng-infinite-scroll.min.js"></script>
<script src="/bower_components/angular-resource/angular-resource.min.js"></script>
<script src="/bower_components/lumx/dist/lumx.min.js"></script>

<script src="/bower_components/loading-bar.js"></script>
<script src="/bower_components/angular-animate.min.js"></script>



<script src="/views/coupon/mycards.js"></script>
<script src="/views/coupon/mycardsdetail.js"></script>
<script src="/views/coupon/shop.js"></script>
<script src="/views/coupon/shopdetail.js"></script>

<script type="text/javascript">
 var userid = "<?=$userid?>";

  

 var myApp = angular.module('myApp', [
    'lumx',
    'infinite-scroll',
    'chieffancypants.loadingBar',
    'ngRoute',
    'myApp.shop',
    'myApp.mycards',
    'myApp.shopdetail',
    'myApp.mycardsdetail'
  ]);

  myApp.config(['$routeProvider', function($routeProvider) {
    $routeProvider.when('/mycards/:id/:con', {
      templateUrl: '/views/coupon/mycards.html',
      controller: 'mycardsCtrl'
    }).when('/mycards/:id/coupon/:cid', {
        templateUrl: '/views/coupon/mycardsdetail.html',
        controller: 'mycardsdetailCtrl'
    }).when('/shop', {
        templateUrl: '/views/coupon/shop.html',
        controller: 'shopCtrl'
    }).when('/shop/:id', {
        templateUrl: '/views/coupon/shopdetail.html',
        controller: 'shopdetailCtrl'
    }).otherwise({redirectTo: '/mycards/0/0'});
  }]);
    
    myApp.controller('appCtrl',['$scope','$http',function($scope,$http) { 
      $scope.go_top=function(){
        $('html,body').animate({scrollTop:0},300);
      };
    }]); 

angular.module('myApp.mycardsdetail', ['lumx']).controller('mycardsdetailCtrl', ['$scope','$http','$routeParams',
  function($scope,$http,$routeParams){
    console.log($routeParams.id); 
      $http.get('/consumer/'+userid+'/coupon/'+$routeParams.cid).success(function(data){
        if (!data.error) {
          $scope.coupon = data.result[0];
              $("#content").after($scope.coupon.content );
                $('#code').qrcode({
                  width: document.body.clientWidth-100,
                  height: document.body.clientWidth-100,
                  text: data.result[0].coupon_url
                });
                wx.ready(function () {
                      shareData = {
                          title:$scope.coupon.subject,
                          desc:$scope.coupon.seller_name,
                          link:"http://www.chinalove99.net:82/coupon/"+$scope.coupon.id+"/get",
                          imgUrl:"http://www.chinalove99.net:82"+$scope.coupon.img_dir
                      };
                      wx.onMenuShareAppMessage(shareData);
                      wx.onMenuShareTimeline(shareData);
                      wx.onMenuShareQQ({
                          trigger: function (res) {
                              alert("暂不支持分享到手机QQ");
                              return false;
                          }
                      });
                });
          };
      });
    $scope.go_back = function(){
      if ($routeParams.id != 0) {
        window.location.href = '#/mycards/'+$routeParams.id+'/0';     
      }else{
        window.location.href = '#/mycards/0/0'; 
      };
    };  
}]); 
</script>

</body>
</html>

